# -*- coding: utf-8 -*-
"""
@Time    : 2025/3/4 20:37 
@Author  : ZhangShenao 
@File    : prompt.py 
@Desc    : prompt提示词模块
"""
from typing import List, Dict

# ReAct Prompt模板
REACT_PROMPT_TEMPLATE = """
{instructions}

TOOLS:
------

You have access to the following tools:

{tools}

To use a tool, please use the following format:

```
Thought: Do I need to use a tool? Yes
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
```

Then wait for Human will response to you the result of action by use Observation.
... (this Thought/Action/Action Input/Observation can repeat N times)
When you have a response to say to the Human, or if you do not need to use a tool, you MUST use the format:

```
Thought: Do I need to use a tool? No
Final Answer: [your response here]
```

Begin!

New input: {input}

"""


def build_react_prompt(instructions: str, query: str, tool_desc: List[Dict], tool_name: str) -> str:
    """
    构造ReAct Prompt
    :param instructions: 系统指令
    :param query: 用户的提问
    :param tool_desc: 外部工具描述
    :param tool_name: 外部工具名称
    :return: React Prompt
    """

    return REACT_PROMPT_TEMPLATE.format(instructions=instructions,
                                        tools=tool_desc,
                                        tool_names=tool_name,
                                        input=query)
